package com.qm.network;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author wb
 * @date 2023-06-16 14:41
 * @description:
 */
public class Internet1 {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getByName("www.baidu.com");
        //public String getHostName()：获取此IP地址的主机名
        String name = address.getHostName();
        //public String getHostAddress()：返回文本显示中的IP地址字符串
        String ip = address.getHostAddress();

        System.out.println("主机名：" + name);
        System.out.println("IP地址：" + ip);
    }
}
